package com.aia.prm.web.ria.app.ui.file;

import com.aia.prm.domain.VOFile;
import com.aia.prm.web.ria.app.PrmApplication;
import com.vaadin.data.Property;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Component;
import com.vaadin.ui.Link;
import com.vaadin.ui.Table;

@SuppressWarnings("serial")
public class FileList extends Table {
	PrmApplication app;
	FileView view;

	FileList(PrmApplication aapp, FileView aview) {
		app = aapp;
		view = aview;
		setSizeFull();

		setColumnCollapsingAllowed(true);
		setColumnReorderingAllowed(true);

		setSelectable(true);
		setImmediate(true);
		addListener((Property.ValueChangeListener) view);

		addGeneratedColumn("pic", new ColumnGenerator() {
			public Component generateCell(Table source, Object itemId, Object columnId) {
				VOFile p = (VOFile) itemId;
				Link l = new Link();
				l.setResource(new ExternalResource("../dbImage.jsp?id=" + p.getF_ID()));
				l.setTargetName("_blank");
				l.setCaption("打开图片");
				return l;
			}
		});
	}

}
